package com.sunrise.xdoc.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.sunrise.xdoc.entity.config.Country;
import com.sunrise.xdoc.entity.config.InternalCode;
import com.sunrise.xdoc.entity.config.InternalCode.InternalCodeType;
import com.sunrise.xdoc.service.AbstractService;
import com.sunrise.xdoc.service.IInternalCodeService;

@Service("internalCodeService")
public class InternalCodeService extends AbstractService implements IInternalCodeService {

	@Override
	public List<Country> getCountries() {
		return getDaoHelper().getDao(Country.class).loadAll();
	}

	@Override
	public List<InternalCode> listByType(InternalCodeType type) {
		DetachedCriteria dc = getDaoHelper().getDao(InternalCode.class).getDetachedCriteria();
		dc.add(Restrictions.eq("type", type));
		return getDaoHelper().getDao(InternalCode.class).findByCriteria(dc);
	}

}
